package main

import (
	"fmt"
	"gorm-study/src/pkg/student/models"
	"gorm-study/src/pkg/utils/dbutil"
)

func main() {
	var existsZhoujiu models.Student
	result := dbutil.DB.Where("name = ?", "周九").First(&existsZhoujiu)
	fmt.Printf("Save 前查询周九，返回数量：%v \n", result.RowsAffected)

	newZhoujiu := models.Student{
		Name:   "周九",
		Age:    50,
		Gender: false,
	}
	result = dbutil.DB.Save(&newZhoujiu)
	fmt.Printf("Save 时 result.RowsAffected：%v \n", result.RowsAffected)

	result = dbutil.DB.Where("name = ?", "周九").First(&existsZhoujiu)
	fmt.Printf("Save 后查询周九，返回数量：%v \n", result.RowsAffected)
	fmt.Printf("Save 后查询周九：%+v \n", existsZhoujiu)
}
